namespace Pna.Framework
{
    using Appccelerate.Formatters;

    using Castle.Core.Logging;
    using Castle.Windsor;

    /// <summary>
    /// The PNA extension base.
    /// </summary>
    public abstract class PnaExtensionBase : IPnaExtension
    {
        /// <summary>
        /// Gets or sets the logger.
        /// </summary>
        public ILogger Logger { get; set; }

        /// <summary>
        /// Gets the name of the describable.
        /// </summary>
        public string Name
        {
            get { return this.GetType().FullNameToString(); }
        }

        /// <summary>
        /// Determines the description of the describable.
        /// </summary>
        /// <returns>
        /// The description.
        /// </returns>
        public abstract string Describe();

        /// <summary>
        /// Called before the start method.
        /// </summary>
        public virtual void BeforeStart()
        {
            this.Logger.InfoFormat("BeforeStart");
        }

        /// <summary>
        /// Starts this extension.
        /// </summary>
        public virtual void Start()
        {
            this.Logger.InfoFormat("Start");
        }

        /// <summary>
        /// Containers the initializing.
        /// </summary>
        /// <param name="container">The container.</param>
        public virtual void ContainerInitializing(IWindsorContainer container)
        {
            this.Logger.InfoFormat("ContainerInitializing");
        }

        /// <summary>
        /// Containers the initialized.
        /// </summary>
        /// <param name="container">The container.</param>
        public virtual void ContainerInitialized(IWindsorContainer container)
        {
            this.Logger.InfoFormat("ContainerInitialized");
        }

        /// <summary>
        /// Called before the stop.
        /// </summary>
        public virtual void BeforeStop()
        {
            this.Logger.InfoFormat("BeforeStop");
        }

        /// <summary>
        /// Stops this instance.
        /// </summary>
        public virtual void Stop()
        {
            this.Logger.InfoFormat("Stop");
        }

        /// <summary>
        /// Called after the stop.
        /// </summary>
        public virtual void AfterStop()
        {
            this.Logger.InfoFormat("AfterStop");
        }
    }
}